package com.yuan.common.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class FiltUtil {

	public static String file2String(File file) throws Exception {
		long begintime = System.currentTimeMillis();
		BufferedReader br = null;
		String ret = null;
		try {
			br = new BufferedReader(new FileReader(file));
			String line = null;
			StringBuffer sb = new StringBuffer((int) file.length());
			while ((line = br.readLine()) != null) {
				sb.append(line);
			}
			ret = sb.toString();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (Exception e) {
				}
			}
		}
		long endtime = System.currentTimeMillis();
		System.out.println("方法3用时" + (endtime - begintime) + "ms");
		System.out.println(ret);
		return ret;
	}
}
